package org.canaan.http.core.single;

import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;

/**
 获取单例的RequestConfig
 @Author Canaan
 @Date 2017/12/14 */
public final class RequestConfigFactory {

    public static final RequestConfig COOKIE_CONFIG;
    public static final RequestConfig DEFAULT_CONFIG;

    static {
        COOKIE_CONFIG = RequestConfig
                .custom()
                .setCookieSpec(CookieSpecs.STANDARD)
                .setSocketTimeout(5000)
                .setConnectTimeout(3000)
                .setConnectionRequestTimeout(3000)
                .build();

        DEFAULT_CONFIG = RequestConfig
                .custom()
                .setSocketTimeout(5000)
                .setConnectTimeout(3000)
                .setConnectionRequestTimeout(3000)
                .build();
    }

    /*
    获取带有cookies 的 RequestConfig 配置
     */
    public static RequestConfig getCookieConfig() {
        return COOKIE_CONFIG;
    }

    /**
     获取默认的
     @return
     */
    public static RequestConfig getDefault() {
        return DEFAULT_CONFIG;
    }


}
